package com.uw.scenic.controller;


import com.uw.scenic.annotation.IgnoreResponseAdvice;
import com.uw.scenic.entity.SysUser;
import com.uw.scenic.exception.ScenicException;
import com.uw.scenic.exception.ScenicException;
import com.uw.scenic.vo.R;
import com.uw.scenic.vo.SysUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 案例：
 * 同样用于消费者的展示
 * 测试基本的crud操作
 */
@Slf4j
@RestController
@RequestMapping("/testUser")
@Api(value = "testUser", tags = "测试基本的curd操作")
public class TestUserController {


//    @Autowired
//    private TestServcie testServcie;


    /**
     * @return
     */
    @ApiOperation(value = "获取详情",notes = "获取详情",httpMethod = "GET")
    @GetMapping("/get")
    public R<SysUserVO> getById() {
//        SysUser sysUser1=testServcie.findById(1L);
        String msg="您已访问【用户微服务】接口";
        SysUserVO sysUser=new SysUserVO();
        sysUser.setUsername(msg);
        return R.success(sysUser);
    }


    /**
     * @return
     */
    @ApiOperation(value = "获取详情2",notes = "获取详情2",httpMethod = "GET")
    @GetMapping("/get2")
    public SysUserVO getById2() {
//        SysUser sysUser1=testServcie.findById(1L);
        String msg="您已访问【用户微服务】接口";
        SysUserVO sysUser=new SysUserVO();
        sysUser.setUsername(msg);
        return sysUser;
    }


    /**
     * @return
     */
    @ApiOperation(value = "获取详情3",notes = "获取详情3",httpMethod = "GET")
    @GetMapping("/get3")
    public SysUserVO getById3() {
//        SysUser sysUser1=testServcie.findById(1L);
        String msg="您已访问【用户微服务】接口";
        SysUserVO sysUser=new SysUserVO();
        sysUser.setUsername(msg);
        return sysUser;
    }


    /**
     * @return
     */
    @ApiOperation(value = "获取详情4",notes = "获取详情4",httpMethod = "GET")
    @GetMapping("/get4")
    public SysUserVO getById4() throws ScenicException {
//        SysUser sysUser1=testServcie.findById(1L);
        String msg="您已访问【用户微服务】接口";
        SysUserVO sysUser=new SysUserVO();
        sysUser.setUsername(msg);
        if(true){
            log.error("发生了业务异常，测试熔断机制");
            throw new ScenicException("发生了业务异常，测试熔断机制");
        }
        return sysUser;
    }
}
